<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>文本框</title>
</head>
<body>
	<input type="text" id='uname' value=''>
	<script type="text/javascript">
	//获取元素
	var uname =document.getElementById('uname');

	//获取value
	// var res = uname.value;
	// //s设置值
	// uname.value ='加油';
	//alert(res);
	//键盘抬起事件

	uname.onkeyup  = function()
	{
		//获取值
		// var v =this.value.toUpperCase()
		// this.value =v;
	}


	//键盘按下事件
	uname.onkeydown = function(e)
	{
			//console.log(e)
		var res =e.key.toUpperCase();
		console.log(res)
		if(res =='BACKSPACE'){
			return true;
		}
		this.value +=res;
		return false;

	}



	</script>
</body>
</html>